<<<<<<< HEAD
=======


>>>>>>> 0c61168a38850f04874b8666cbf4a3ec72a1b435
class Solution 
{
public:
    int lengthOfLongestSubstring(string s) 
    {
<<<<<<< HEAD
        int hash[128]={0};
        int n=s.size();
        int ret=0;
        for(int i=0,j=0;j<n;)
        {
            //进窗口
            hash[s[j]]++;
            //不满足出窗口
            while(hash[s[j]]>1)
            {
                hash[s[i++]]--;
            }
            //此时记录满足的窗口大小
            cout<<j-i+1<<endl;
            //更新答案是在出窗口之前还是之后要考虑清楚 进窗口需要更新 出窗口也要更新 就放在出窗口后面
            ret=max(ret,j-i+1);
            j++;
        }
=======
        int ret=0;
        set<char> tem;
        int n =s.size();
        int i=0,j=0;
        for(i=0,j=0;j<n;)
        {
            if(!tem.count(s[j]))
            {
                tem.insert(s[j]);
                j++;
            }
            else
            {
                ret=max(ret,j-i);
                tem.erase(s[i++]);
            }
        }
        ret=max(ret,j-i);
>>>>>>> 0c61168a38850f04874b8666cbf4a3ec72a1b435
        return ret;
    }
};